package com.etc.controller;

import com.etc.entity.CommentResult;
import com.etc.entity.Room;
import com.etc.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RoomController {
    @Autowired
    private RoomService roomService;

    @RequestMapping("room/insert")
    public CommentResult insert(@RequestBody Room room)
    {
        int result = roomService.insert(room);
        if (result>0){
            return new CommentResult(200,"success");
        }
        return new CommentResult(444,"failed");
    }

    @RequestMapping("room/insertNext/{id}")
    public CommentResult insertNext(@PathVariable("id") Integer id)
    {
        int result = roomService.insertNext(id);
        if (result>0){
            return new CommentResult(200,"success");
        }
        return new CommentResult(444,"failed");
    }
}
